﻿namespace com.oakwoodsys.ConsultantCareDao
{
    using com.oakwoodsys.Extensions.SharePointExtensions;
    using com.oakwoodsys.SharePoint;

    using Microsoft.SharePoint;

    public partial class Recruiter
    {
        #region Fields

        SPUserInfoExpanded _UserInfo;

        #endregion Fields

        #region Properties

        public string CalendarPathDescription
        {
            get
            {
                string[ ] s = CalendarPath.Split( ',' );
                if ( s.Length >= 1 )
                    return s[ 1 ].Trim( );
                else
                    return string.Empty;
            }
        }

        public string CalendarPathUrl
        {
            get
            {
                string[ ] s = CalendarPath.Split( ',' );
                if ( s.Length >= 1 )
                    return s[ 0 ].Trim( );
                else
                    return string.Empty;
            }
        }

        public SPUserInfoExpanded UserInfo
        {
            get
            {
                if ( _UserInfo == null )
                {
                    using ( SPSite spSite = new SPSite( WebUrl ) )
                    {
                        using ( SPWeb spWeb = spSite.OpenWeb( ) )
                        {
                            SPUser user = spWeb.SiteUsers.GetByID( this.RecruiterId.Value );
                            _UserInfo = user.ToUserInfoExpanded( );
                        }
                    }
                }
                return _UserInfo;
            }
        }

        #endregion Properties
    }
}